<?php
/**
 * Display a table of feedbacks for a parent/block.
 * Meant to be called by table's pagination.
 *
 * @package    mahara
 * @subpackage artefact-feedback
 * @author     laurent.opprecht@gmail.com
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2011 University of Geneva http://www.unige.ch/
 *
 */
define('INTERNAL', 1);
define('MENUITEM', 'myportfolio');

require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once(get_config('libroot') . 'view.php');
safe_require('artefact', 'feedback');

$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);

$extradata = json_decode(param_variable('extradata'));
$parent_id = $extradata ? $extradata->parent_id : 0;
$show_private = $extradata ? $extradata->show_private : 0;

$count = ArtefactTypeFeedback::count_feedbacks_onparent($parent_id, $show_private);
$rows = FeedbackTable::build_rows($parent_id, $show_private, $limit, $offset);
$pagination = FeedbackTable::build_pagination($parent_id, $show_private, $count, $limit, $offset);

$data = array(
    'count' => $count,
    'limit' => $limit,
    'offset' => $offset,
    'tablerows' => $rows,
    'pagination' => $pagination['html'],
    'pagination_js' => $pagination['javascript'],
);

$message = '';
json_reply(false, (object) array('message' => $message, 'data' => $data));

?>